﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace xiaolanshu
{
    public partial class 底妆_反馈 : Form
    {
        public 底妆_反馈()
        {
            InitializeComponent();
            //string constr = @"server=.\SqlExpress;database=商品详情;integrated security=SSPI";
            //SqlConnection conn = new SqlConnection(constr);
        }

       

        private void 底妆_反馈_Load(object sender, EventArgs e)
        {
            SqlConnection conn = SQLTools.conn;
            //SqlConnection conn = new SqlConnection(@"server=.\SqlExpress;database=商品详情;integrated security=SSPI");
            string sql = "select 名称 from 底妆";
            SqlCommand cmd = new SqlCommand(sql, conn);
            conn.Open();
            SqlDataReader rd = cmd.ExecuteReader();
            while(rd.Read())
            {
                comboBox1.Items.Add(rd[0].ToString());
            }
            rd.Close();
            conn.Close();
        }

        private void uiTrackBar1_ValueChanged(object sender, EventArgs e)
        {
            textBox1.Text = uiTrackBar1.Value.ToString();
        }

        private void uiTrackBar2_ValueChanged(object sender, EventArgs e)
        {
            textBox2.Text = uiTrackBar2.Value.ToString();
        }

        private void uiTrackBar3_ValueChanged(object sender, EventArgs e)
        {
            textBox3.Text = uiTrackBar3.Value.ToString();
            if (uiTrackBar4.Value < 10 && uiTrackBar1.Value < 10 && uiTrackBar2.Value < 10 && uiTrackBar3.Value < 10)
            {
                MessageBox.Show("禁止恶意刷分！");
            }
        }

        private void uiTrackBar4_ValueChanged(object sender, EventArgs e)
        {
            textBox4.Text = uiTrackBar4.Value.ToString();
           
        }

        private void uiButton3_Click(object sender, EventArgs e)
        {
            SqlConnection conn = SQLTools.conn;
            //SqlConnection conn = new SqlConnection(@"server=.\SqlExpress;database=商品详情;integrated security=SSPI");
            String sql = @"insert into 底妆反馈 values(@产品,@整体评价,@服帖度,@持妆度,@遮瑕力)";
            SqlCommand cmd = new SqlCommand(sql, conn);           
            SqlParameter _产品 = new SqlParameter("@产品", SqlDbType.VarChar, 30); 
            SqlParameter _整体评价 = new SqlParameter("@整体评价", SqlDbType.Int);
            SqlParameter _服帖度 = new SqlParameter("@服帖度", SqlDbType.Int);
            SqlParameter _持妆度 = new SqlParameter("@持妆度", SqlDbType.Int);
            SqlParameter _遮瑕力 = new SqlParameter("@遮瑕力", SqlDbType.Int);          
            cmd.Parameters.Add(_产品);
            cmd.Parameters.Add(_整体评价);
            cmd.Parameters.Add(_服帖度);
            cmd.Parameters.Add(_持妆度);
            cmd.Parameters.Add(_遮瑕力);
            _产品.Value = comboBox1.Text;
            _整体评价.Value = uiTrackBar4.Value;
            _服帖度.Value = uiTrackBar1.Value;
            _持妆度.Value = uiTrackBar2.Value;
            _遮瑕力.Value = uiTrackBar3.Value;           
            try
            {
                conn.Open();
                cmd.ExecuteNonQuery();
                MessageBox.Show("您已成功提交，谢谢您的反馈！", "成功");
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message, "失败");
            }
            finally
            {
                conn.Close();
            }
        }

        private void uiButton1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void uiButton2_Click(object sender, EventArgs e)
        {
            this.comboBox1.Text = "";            
            this.uiTrackBar1.Value = 0;
            this.uiTrackBar2.Value = 0;
            this.uiTrackBar3.Value = 0;
            this.uiTrackBar4.Value = 0;
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

       
    }
}
